
class Yaoshaizidange extends egret.Sprite {
  private mc: egret.MovieClip
  public constructor() {
    super()
    this.once(eui.UIEvent.COMPLETE, this.onComplete, this)
  }
  private onComplete() {
    
  }
  public playAction(finalDian, bigShaizi: boolean = false) {
    StageData.soundObj.soundSinglePlay("openmall");
    var name = 'yaoshaizidange'
    var spr1: egret.MovieClip = new egret.MovieClip();
    var data = RES.getRes(name + "_json");
    var texture = RES.getRes(name + "_png");
    var mcDataFactory: egret.MovieClipDataFactory = new egret.MovieClipDataFactory(data,texture);
    spr1 = new egret.MovieClip(mcDataFactory.generateMovieClipData('shaiz'))

    spr1.width = 120
    spr1.height = 120
    this.mc = spr1

    this.addChild(this.mc)
    // this.mc.gotoAndPlay(1)
    this.mc.play(1)    
    // this.mc.play()      
    console.log('this.mc', this.mc);
    this.mc.addEventListener(egret.Event.COMPLETE, (e: egret.Event) => {
      this.removeChild(this.mc)
      this.dispatchEvent(new egret.Event('playEnd'))
      const shaizi = MyLibrary.createBitmapByName(`Dice1_00${finalDian}_png`)
      if (bigShaizi) {
        shaizi.scaleX = shaizi.scaleY = 1.5
      }
      console.log('add shaizi');
      this.addChild(shaizi)
    }, this)
  }

  public playNoAction(finalDian, bigShaizi: boolean = false) {
    const shaizi = MyLibrary.createBitmapByName(`Dice1_00${finalDian}_png`)
    if (bigShaizi) {
      shaizi.scaleX = shaizi.scaleY = 1.5
    }
    console.log('add shaizi');
    this.addChild(shaizi)
  }
}
